// import { stringify } from "querystring";

const list = [
  { id: 0, dateTime: new Date().valueOf(), startupRate: '30%', workshop: '车间一' },
  { id: 1, dateTime: new Date().valueOf(), startupRate: '50%', workshop: '车间二' },
  { id: 2, dateTime: new Date().valueOf(), startupRate: '60%', workshop: '车间三' },
  { id: 3, dateTime: new Date().valueOf() - 24 * 3600 * 1000, startupRate: '33%', workshop: '车间四' },
  { id: 4, dateTime: new Date().valueOf() - 24 * 3600 * 1000, startupRate: '80%', workshop: '车间五' },
  { id: 5, dateTime: new Date().valueOf() - 24 * 3600 * 1000, startupRate: '85%', workshop: '车间六' },
  { id: 6, dateTime: new Date().valueOf() - 24 * 3600 * 1000, startupRate: '96%', workshop: '车间七' }
]
export default [
  // 查询
  {
    url: '/bdc/startup-rate-monitor',
    type: 'get',
    response: config => {
      const res = config.query
      let data = [].concat(list)
      if (res.workshop && res.workshop !== '') {
        data = data.filter(a => a.workshop.indexOf(res.workshop) >= 0)
      }
      if (res.dateTime && res.dateTime !== null) {
        data = data.filter(a => a.dateTime > new Date(res.dateTime).valueOf() && Number(a.dateTime) - new Date(res.dateTime).valueOf() < 24 * 3600 * 1000)
      }
      return {
        code: 20000,
        data: data,
        message: JSON.stringify(res)
      }
    }
  }
]
